package com.learn.properties;

import lombok.Getter;
import lombok.Setter;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.stereotype.Component;
import org.springframework.validation.annotation.Validated;

import javax.validation.constraints.Email;
import java.util.Date;
import java.util.List;
import java.util.Map;

@Component
@ConfigurationProperties(prefix = "app")
@Getter
@Setter
@Validated
public class AppPropertiesYml {
    private String string;
    private Boolean bool;
    
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date dateTime;
    
    private Map<String, String> map;
    private List<String> list;
    private Author author;
    
    private String fileUploadPath;
    
    @Getter
    @Setter
    @Validated
    public static class Author {
        private String name;
        private Integer age;
        
        @Email
        private String email;
    }
}